﻿<%@ Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Process Mapper</title>
    
<script language="javascript" type="text/javascript" src="Default.js">
</script>

</head>
<body style="font-size: x-small; font-family: Arial" onload="body_onload()">
    <form id="form1" runat="server">
  
  <asp:UpdateProgress 
    ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"
    DynamicLayout="True" DisplayAfter="2000"> 
         <ProgressTemplate>
         <img id="imgProgress"  src="images/indicator.gif" alt="..."/>
         <asp:Label ID="lblProgressMessage" runat="server" Text="Please wait..." />
             </ProgressTemplate>
         </asp:UpdateProgress>
  
        <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeOut="600">
        </asp:ScriptManager>
  <div style="position:absolute; top:0px;left:10px">
</div>   
         
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" >
  <ContentTemplate>
   <div>
    <asp:Label ID="lblErrorMessage" runat="server" ForeColor="Red" ></asp:Label>
    <cc1:HoverMenuExtender ID="hme2" runat="Server"
    TargetControlID="lblErrorMessage"
    PopupControlID="txtStacktrace"
    HoverCssClass="popupHover"
    PopupPosition="Bottom"
    OffsetX="-2"
    OffsetY="4"
    PopDelay="50" />

 <cc1:TabContainer ID="tabsHIPO" runat="server"  ActiveTabIndex="5" BackColor="ButtonFace"  Font-Bold="True">
 
      <cc1:TabPanel ID="tabTree" runat="server" HeaderText="TabPanel1"   >
         <HeaderTemplate>
             Process Tree
         </HeaderTemplate>
         <ContentTemplate>
         
         <table style="font:x-small Arial;">
         <tr>
                 
         
         <td valign="top" style="height: 539px"> 
             <table>
                 <tr>

                 <td align="left" nowrap="nowrap" valign="top">
                     <asp:DropDownList id="ddlVSDFilesList" runat="server" Font-Size="X-Small">
                    </asp:DropDownList>
                    <cc1:ListSearchExtender ID="ListSearchExtender2" runat="server" TargetControlID="ddlVSDFilesList" Enabled="True">
                </cc1:ListSearchExtender>                 </td>
                    <td valign="top">
                <asp:ImageButton ID="btnCreateTree" runat="server" ImageUrl="~/images/Tree.jpg" Height="19px" />
                     </td>

                     <td style="width: 1px; height: 21px" valign="top">
                     </td>
                 </tr>
             </table>
       </td>
         </tr>
         </table>
         
         </ContentTemplate>
     </cc1:TabPanel>
     
            <cc1:TabPanel ID="tabVisio" runat="server" HeaderText="TabPanel1">
                <HeaderTemplate>
                Process Map
               </HeaderTemplate>
                <ContentTemplate>
                <div style="font:x-small Arial;">
                    <table>
                        <tr>
                     <td style="height: 21px" valign="middle">
                        Batch Files
                     </td>
                     <td style="height: 21px" valign="top">
                     </td>
                     <td style="height: 21px" valign="top">
                <asp:DropDownList ID="ddlFilesList" runat="server" Font-Size="X-Small" >
                </asp:DropDownList>
                 <cc1:ListSearchExtender ID="ListSearchExtender1" runat="server" TargetControlID="ddlFilesList" Enabled="True">
                </cc1:ListSearchExtender>
                 </td>
                 <td valign="top">
                    <asp:ImageButton ID="btnOpen" runat="server" ImageUrl="~/images/Open.jpg"  Height="16px"  />
                 </td>                 
                 <td valign="top">
                    <asp:ImageButton ID="btnCreateVisio" runat="server" ImageUrl="~/images/Visio.jpg"  Height="16px"  />
                 </td>                 
                <td align="left" nowrap="nowrap" valign="top">
                    <asp:ImageButton ID="btnRefresh" runat="server" Height="16px" ImageUrl="~/images/refresh.jpeg" /></td>
                 <td align="left" nowrap="nowrap" valign="top">
                    <asp:ImageButton ID="btnSave" runat="server" ImageUrl="~/images/Save.jpg" Height="16px"  /></td>
               <td align="left" nowrap="nowrap" valign="top">
                    <asp:ImageButton ID="btnPrint" runat="server" ImageUrl="~/images/Print.jpg" Height="16px"  /></td>
                <td>
                 <table border="0" cellspacing="0" cellpadding="0">
                 <tr>
                             <td valign="bottom">
                                 &nbsp;<asp:ImageButton ID="btnLessDepth" runat="server" ImageUrl="~/images/downbutton.jpg" 
                                 Height="16px" />
                             </td>

                             <td valign="top">
                                 <asp:TextBox ID="txtDepth" runat="server" Font-Size="X-Small" Width="10px">1</asp:TextBox></td>
                                    <cc1:NumericUpDownExtender ID="ajaxUpDownExtender" runat="server" Minimum="1" Maximum="9"
                                      TargetButtonDownID="btnLessDepth"
                                      TargetButtonUpID="btnMoreDepth" TargetControlID="txtDepth" Enabled="True" RefValues="" ServiceDownMethod="" ServiceDownPath="" ServiceUpMethod="" Tag="" Width="0">
                                    </cc1:NumericUpDownExtender>
                             <td valign="bottom">
                                <asp:ImageButton ID="btnMoreDepth" runat="server" ImageUrl="~/images/upbutton.jpg" Height="16px" />
                             </td>                                
                             <td valign="middle">
                                 <asp:TextBox ID="lblMaxDepth" Visible="false" runat="server" Enabled="False" Font-Size="X-Small" ReadOnly="True"
                                     Text="9" Width="10px"></asp:TextBox>
                             </td>
                 </tr>
                 </table>
                </td>                 

                 <td style="width: 21px; height: 21px" valign="middle" align="right">
                    <asp:Label ID="lblPageWidth" runat="server" Text="8.5" Enabled="False"></asp:Label>
                 </td>
                 <td style="width: 21px; height: 21px" valign="middle">
                    <asp:Label ID="lblPageHeight" runat="server" Text="11" Enabled="False"></asp:Label>
                 </td>
                <td align="left" nowrap="nowrap" valign="top">
                    <asp:CheckBox ID="chkExpandable" runat="server" Text="Expand/Collapse " Checked="True" Width="104px"/></td>
                <td align="left" nowrap="nowrap" style="width: 79px" valign="top">
                    <asp:CheckBox ID="chkExpandAll" runat="server" Text="Expand All" Checked="True" Width="76px"/></td>
                <td align="left" nowrap="nowrap" style="width: 3px" valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="7" nowrap="nowrap" valign="middle">
                <asp:Label ID="lblPages" runat="server" Font-Size="X-Small" Font-Bold="True"></asp:Label></td>
            </tr>
        </table>
                <asp:HiddenField ID="hdnShapeID" runat="server" />
 
                <iframe id="pnlVisio" runat="server" height="530" scrolling="no" style="width: expression((document.body.clientWidth -20).toString() + 'px');" 
                   src="VisioViewer.aspx">
               </iframe>            
              </div>              
              </ContentTemplate>
            </cc1:TabPanel>
            
            <cc1:TabPanel ID="tabFilesList" runat="server" HeaderText="TabPanel2">
                <HeaderTemplate>
                    Files List
                </HeaderTemplate>        
                <ContentTemplate>
                   <table style="width: 100%">
                    <tr>
                        <td style="width:100%" valign="top">
                            <asp:Panel ID="Panel1" runat="server" Height="520px" ScrollBars="Auto" Width="100%"
                                BorderStyle="Inset" BorderWidth="2px">
                                <br />
                                    <asp:DataGrid ID="dgrdFilesList" runat="server" AllowSorting="True" CellPadding="4" Font-Size="XX-Small" ForeColor="#333333" AutoGenerateColumns="False">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <EditItemStyle BackColor="#999999" />
                                <SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                                <ItemStyle BackColor="#F7F6F3" ForeColor="#333333" Wrap="False" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                               <Columns>
                                   <asp:BoundColumn DataField="Name" HeaderText="File" SortExpression="Name"></asp:BoundColumn>
                                   <asp:BoundColumn DataField="Path" HeaderText="Path" SortExpression="Path"></asp:BoundColumn>
                                   <asp:BoundColumn DataField="Date" HeaderText="Date Time" DataFormatString="{0:d}" SortExpression="Date"></asp:BoundColumn>
                                   <asp:BoundColumn DataField="Size" HeaderText="Size" DataFormatString="{0:n}" SortExpression="Size">
                                   <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                                           Font-Underline="False" HorizontalAlign="Right" />
                                   </asp:BoundColumn>
                                   <asp:BoundColumn DataField="CurrDate" DataFormatString="{0:d}" HeaderText="Current Date Time" SortExpression="CurrDate"></asp:BoundColumn>                                  
                                   <asp:BoundColumn DataField="CurrSize" DataFormatString="{0:d}" HeaderText="Current Size" SortExpression="CurrSize">
                                       <ItemStyle HorizontalAlign="Right" />
                                   </asp:BoundColumn>                                  
                                   <asp:BoundColumn DataField="CurrStatus" DataFormatString="{0:d}" HeaderText="Status" SortExpression="CurrStatus">
                                       <ItemStyle HorizontalAlign="Center" />
                                   </asp:BoundColumn>                                  
                               </Columns>
                            </asp:DataGrid>
                            </asp:Panel>
                        </td>
                   </tr>
                </table>      
        
                </ContentTemplate>
            </cc1:TabPanel>
            
            <cc1:TabPanel ID="tabText" runat="server" HeaderText="TabPanel4">
                <ContentTemplate>
                    <asp:Label ID="lblBatchFileText" runat="server" BackColor="Black" Font-Bold="True" ForeColor="White"></asp:Label><br />
                    <asp:TextBox ID="txtBat" runat="server" Height="520px" ReadOnly="True" TextMode="MultiLine"
                        Width="100%" Wrap="False"></asp:TextBox>
                </ContentTemplate>
                <HeaderTemplate>
                    Batch File Text
                </HeaderTemplate>
            </cc1:TabPanel>
            
            <cc1:TabPanel ID="tabSettings" runat="server" HeaderText="TabPanel3">
                <HeaderTemplate>
                    Settings
                </HeaderTemplate>
                
                <ContentTemplate>
                <div style="background-color:ButtonFace; font-size:x-small" >
                
                
                <table>
                <tr>
                <td>
                     <asp:Panel ID="Panel2" runat="server" GroupingText="Paper Options" Width="156px">
                        <asp:CheckBox ID="chkLandscape" runat="server"  Text="Landscape" />
                        Orientation<br /><asp:CheckBox ID="chkLegal" runat="server"  Text="Legal Size" /></asp:Panel>
               </td>
                <td>
                    <asp:Panel ID="Panel3" runat="server" GroupingText="Detect Changed Files" Width="158px">
                        <br />
                        &nbsp;Mark files created after:
                        <br />
                        &nbsp; &nbsp;&nbsp;
             <asp:TextBox ID="txtMarkDate" runat="server" Width="77px"></asp:TextBox>
        <asp:Button ID="btnCalendar" runat="server" Text="..." />
                        <cc1:CalendarExtender 
                        ID="CalendarExtender1" 
                        TargetControlID="txtMarkDate"
                        PopupButtonID="btnCalendar"
                        runat="server" Enabled="True">
                        </cc1:CalendarExtender>
        <br />
                    </asp:Panel>
                </td>
                <td>
                <td>
                    <asp:Panel ID="Panel4" runat="server" GroupingText="Bypass Checked Files" Width="158px">
                        <asp:CheckBoxList ID="cblSkipped" runat="server">
                    </asp:CheckBoxList>                    
                    </asp:Panel>
                </td>
                <td>
                <asp:CheckBox id="chkHideInputs" runat="server" Text="Supress Input Shapes" />
                </td>
                <td>
                </td>
                </tr>
                </table>

        </div>                    
                </ContentTemplate>
            </cc1:TabPanel>
            
     <cc1:TabPanel ID="tabComments" runat="server" HeaderText="TabPanel1">
         <HeaderTemplate>
             Annotations
         </HeaderTemplate>         
         <ContentTemplate>
             <table style="height: 510px">
                 <tr>
                     <td style="overflow:auto;" valign="top">
             &nbsp;<asp:Label ID="lblTreeName" runat="server" Font-Size="X-Small" BackColor="Black" Font-Bold="True" ForeColor="White"></asp:Label>
  <br />
              <asp:Panel ID="Panel5" runat="server" Height="545px" ScrollBars="Auto" Width="100%"
                BorderStyle="Inset" BorderWidth="2px">
                <asp:TreeView ID="tvwStructure" runat="server" Font-Size="XX-Small"
                    PopulateNodesFromClient="False" ShowLines="True">
                    <Nodes><asp:TreeNode Text="Create Process Map for Tree" Value="Create Process Map for Tree"></asp:TreeNode></Nodes>
                </asp:TreeView>

            </asp:Panel>                     
                     </td>
                     <td style="" valign="top">
           <asp:Label ID="lblCommentFileName" runat="server" BackColor="Black" Font-Bold="True" ForeColor="White"></asp:Label>
             <br />
              <asp:Button ID="btnUpdateComment" runat="server" Font-Size="X-Small" OnClick="btnUpdateComment_Click"
                      Text="Update Comments" />
              <br />
              <asp:Panel ID="Panel6" runat="server" Height="400px" width="100%" ScrollBars="Auto" Font-Size="x-Small" Font-Bold="false" BorderStyle="Inset" BorderWidth="2px">
                 <asp:CheckBoxList ID="cblComments" runat="server"  DataSourceID="sdsComments" DataTextField="CommentLine" DataValueField="IsVisibleLine">
                 </asp:CheckBoxList>    
                 <asp:SqlDataSource ID="sdsComments" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:Database %>"
                     SelectCommand="SELECT [IsVisibleLine], [CommentLine] FROM [FileCommentLines] 
                     WHERE ([FileID] = @FileID) ORDER BY [LineId]">
                     <SelectParameters>
                         <asp:Parameter Name="FileID" Type="Int32" />
                     </SelectParameters>
                 </asp:SqlDataSource>
             </asp:Panel>

            Comments Dictionary Text
             <br />
                    <asp:TextBox ID="txtComments" runat="server" BorderStyle="Inset" BorderWidth="2px" 
                        Font-Size="X-Small" Height="149px" TextMode="MultiLine" Width="124%" Wrap="False"></asp:TextBox>
             <br />
                     </td>
                 </tr>
             </table>
             &nbsp;
         </ContentTemplate>

     </cc1:TabPanel>
     
     <cc1:TabPanel ID="tabShapeText" runat="server" HeaderText="TabPanel2">
         <ContentTemplate>
                    <asp:Label ID="lblShapeFile" runat="server" Font-Names="Arial" Font-Size="X-Small" BackColor="Black" Font-Bold="True" ForeColor="White"></asp:Label>
                    <asp:TextBox ID="txtShapeFile" runat="server" Font-Names="Courier New" Font-Size="X-Small"
                        Height="500px" TextMode="MultiLine" Width="100%"></asp:TextBox>
         </ContentTemplate>
         <HeaderTemplate>
             Shape File Text
         </HeaderTemplate>
     </cc1:TabPanel>

        </cc1:TabContainer>

    <asp:TextBox ReadOnly="true" ID="txtStacktrace" runat="server" BorderStyle="Inset" BorderWidth="2px" Height="80px" Width="400px"
    Font-Size="X-Small" TextMode="MultiLine" Wrap="False"></asp:TextBox>
   
    </div>
  </ContentTemplate>
  </asp:UpdatePanel> 
  
  
  
       <asp:SqlDataSource ID="sdsBatCalledFiles" runat="server" ConnectionString="<%$ ConnectionStrings:Database %>"
            DeleteCommand="DELETE FROM [BatCalledFiles] WHERE [BatFileID] = @BatFileID" InsertCommand="INSERT INTO [BatCalledFiles] ([BatFileID], [CalledFileID]) VALUES (@BatFileID, @CalledFileID)"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" SelectCommand="SELECT [BatFileID], [CalledFileID] FROM [BatCalledFiles]"
            UpdateCommand="UPDATE [BatCalledFiles] SET [CalledFileID] = @CalledFileID WHERE [BatFileID] = @BatFileID">
            <DeleteParameters>
                <asp:Parameter Name="BatFileID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="BatFileID" Type="Int32" />
                <asp:Parameter Name="CalledFileID" Type="Int32" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="CalledFileID" Type="Int32" />
                <asp:Parameter Name="BatFileID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        
        
        <asp:SqlDataSource ID="sdsCommentsDictionary" runat="server" ConnectionString="<%$ ConnectionStrings:Database %>"
            DeleteCommand="DELETE FROM [CommentsDictionary] WHERE [FileID] = @FileID" 
            InsertCommand="INSERT INTO [CommentsDictionary] ([FileID], [CommentLines]) VALUES (@FileID, @CommentLines)"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" 
            SelectCommand="SELECT [FileID], [UserID], [CommentLines] FROM [CommentsDictionary] WHERE [FileID]=@FileID"
            UpdateCommand="UPDATE [CommentsDictionary] SET [UserID] = @UserID, [CommentLines] = @CommentLines WHERE [FileID] = @FileID">
            <DeleteParameters>
                <asp:Parameter Name="FileID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="FileID" Type="Int32" />
                <asp:Parameter Name="CommentLines" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="UserID" Type="Int32" />
                <asp:Parameter Name="CommentLines" Type="String" />
                <asp:Parameter Name="FileID" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:Parameter Name="FileID" />
            </SelectParameters>
        </asp:SqlDataSource>
      
        
        <asp:SqlDataSource ID="sdsFileCommentLines" runat="server" ConnectionString="<%$ ConnectionStrings:Database %>"
            DeleteCommand="DELETE FROM [FileCommentLines] WHERE [FileID] = @FileID" 
            InsertCommand="INSERT INTO [FileCommentLines] ([FileID], [LineId], [IsVisibleLine], [CommentLine]) VALUES (@FileID, @LineId, @IsVisibleLine, @CommentLine)"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" 
            SelectCommand="SELECT [FileID], [LineId], [IsVisibleLine], [CommentLine] FROM [FileCommentLines] WHERE [FileID]=@FileID"
            UpdateCommand="UPDATE [FileCommentLines] SET [IsVisibleLine] = @IsVisibleLine WHERE [FileID] = @FileID AND  [LineId] = @LineId">
             <SelectParameters>
                <asp:Parameter Name="FileID" Type="Int32" />
            </SelectParameters>
           <DeleteParameters>
                <asp:Parameter Name="FileID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="FileID" Type="Int32" />
                <asp:Parameter Name="LineId" Type="Int32" />
                <asp:Parameter Name="IsVisibleLine" Type="Boolean" />
                <asp:Parameter Name="CommentLine" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="LineId" Type="Int32" />
                <asp:Parameter Name="IsVisibleLine" Type="Boolean" />
                <asp:Parameter Name="FileID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        
        
        <asp:SqlDataSource ID="sdsTextFiles" runat="server" ConnectionString="<%$ ConnectionStrings:Database %>"
            DeleteCommand="DELETE FROM [TextFiles] WHERE [FileID] = @FileID" 
            InsertCommand="INSERT INTO [TextFiles] ([Name], [Path], [Type], [Size], [Date], [CurrSize], [CurrDate]) 
                                        VALUES (@Name, @Path, @Type, @Size, @Date, @CurrSize, @CurrDate)"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" 
            SelectCommand="SELECT [FileID], [Name], [Path], [Type], [Size], [Date], [CurrSize], [CurrDate] FROM [TextFiles] 
             WHERE [Name]=@Name AND [Path]=@Path AND [Type]=@Type"
            UpdateCommand="UPDATE [TextFiles] 
                       SET [Name] = @Name, [Path] = @Path, [Type] = @Type, [Size] = @Size, [Date] = @Date, 
                       [CurrSize] = @CurrSize, [CurrDate] = @CurrDate WHERE [FileID] = @FileID">
            
            <SelectParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Path" Type="String" />
                <asp:Parameter Name="Type" Type="String" />
             </SelectParameters>
            
            <DeleteParameters>
            <asp:Parameter Name="FileID" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String"></asp:Parameter>
            <asp:Parameter Name="Path" Type="String"></asp:Parameter>
            <asp:Parameter Name="Type" Type="String"></asp:Parameter>
            <asp:Parameter Name="Size" Type="String"></asp:Parameter>
            <asp:Parameter Name="Date" Type="String"></asp:Parameter>
            <asp:Parameter Name="CurrSize" Type="String"></asp:Parameter>
            <asp:Parameter Name="CurrDate" Type="String"></asp:Parameter>
        </InsertParameters>
        
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String"></asp:Parameter>
            <asp:Parameter Name="Path" Type="String"></asp:Parameter>
            <asp:Parameter Name="Type" Type="String"></asp:Parameter>
            <asp:Parameter Name="Size" Type="String"></asp:Parameter>
            <asp:Parameter Name="Date" Type="String"></asp:Parameter>
            <asp:Parameter Name="CurrSize" Type="String"></asp:Parameter>
            <asp:Parameter Name="CurrDate" Type="String"></asp:Parameter>
            <asp:Parameter Name="FileID" Type="Int32"></asp:Parameter>
        </UpdateParameters>
    </asp:SqlDataSource>
    

        <asp:sqldatasource id="sdsTreeNodes" runat="server" 
            connectionstring="<%$ ConnectionStrings:Database %>"
            providername="<%$ ConnectionStrings:Database.ProviderName %>" 
            
            selectcommand="SELECT [VSDFileID], [NodeID], [ParentNodeID], [Text], 
                                  [Value], [Tooltip], [ImageTooltip], [Expanded], [Selected], [Checked], 
                                  [Target], [Depth], [ShapeId], [ParentShapeId] 
                           FROM [TreeNodes]  
                           WHERE [VSDFileID] = @VSDFileID"
            deletecommand="DELETE FROM [TreeNodes] WHERE [VSDFileID] = @VSDFileID" 
            insertcommand="INSERT INTO [TreeNodes] ([VSDFileID], [NodeID], [ParentNodeID], [Text], [Value], [Tooltip], [ImageTooltip], [Expanded], [Selected], [Checked], [Target], [Depth], [ShapeId], [ParentShapeId]) VALUES (@VSDFileID, @NodeID, @ParentNodeID, @Text, @Value, @Tooltip, @ImageTooltip, @Expanded, @Selected, @Checked, @Target, @Depth, @ShapeId, @ParentShapeId)"
            updatecommand="INSERT INTO [TreeNodes] 
                           Select @NewVSDFileId AS VSDFileID, [NodeID], [ParentNodeID], [Text], [Value], [Tooltip], [ImageTooltip], [Expanded], [Selected], [Checked], [Target], [Depth], [ShapeId], [ParentShapeId] 
                           FROM TreeNodes AS TreeNodes_1 WHERE [VSDFileID] = @VSDFileID" >
            
            <selectParameters>
                <asp:Parameter Name="VSDFileID" Type="Int32"></asp:Parameter>
            </selectParameters>
            
            <UpdateParameters>
                <asp:Parameter Name="NewVSDFileId" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="VSDFileID" Type="Int32"></asp:Parameter>
            </UpdateParameters>            
            
            <DeleteParameters>
                <asp:Parameter Name="VSDFileID" Type="Int32"></asp:Parameter>
            </DeleteParameters>
            
            <InsertParameters>
                <asp:Parameter Name="VSDFileID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="NodeID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ParentNodeID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="Text" Type="String"></asp:Parameter>
                <asp:Parameter Name="Value" Type="String"></asp:Parameter>
                <asp:Parameter Name="Tooltip" Type="String"></asp:Parameter>
                <asp:Parameter Name="ImageTooltip" Type="String"></asp:Parameter>
                <asp:Parameter Name="Expanded" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Selected" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Checked" Type="Boolean"></asp:Parameter>
                <asp:Parameter Name="Target" Type="String"></asp:Parameter>
                <asp:Parameter Name="Depth" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ShapeId" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ParentShapeId" Type="Int32"></asp:Parameter>
            </InsertParameters>

            </asp:sqldatasource>

        <asp:sqldatasource 
            ID="sdsUtilTreeNodes" 
            runat="server" 
            
            ConnectionString="<%$ ConnectionStrings:Database %>"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" 
            
            SelectCommand="SELECT [NodeID] FROM [TreeNodes] WHERE [VSDFileID] = @VSDFileID and [ShapeId]=@ShapeId" 
                           
            UpdateCommand="UPDATE [TreeNodes] Set [ShapeId]=@ShapeId WHERE [VSDFileID] = @VSDFileID AND [NodeID]=@NodeID">
            
            <selectParameters>
                <asp:Parameter Name="VSDFileID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ShapeId" Type="Int32"></asp:Parameter>
            </selectParameters>
            
            <UpdateParameters>
                <asp:Parameter Name="NodeID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="VSDFileID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ShapeId" Type="Int32" />
            </UpdateParameters>            
            
       </asp:sqldatasource>

        <asp:SqlDataSource ID="sdsUsers" runat="server" 
          ConnectionString="<%$ ConnectionStrings:Database %>"
            DeleteCommand="DELETE FROM [Users] WHERE [UserID] = @UserID" 
            InsertCommand="INSERT INTO [Users] ([UserName]) VALUES (@UserName)"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" 
            SelectCommand="SELECT [UserID], [UserName] FROM [Users] WHERE [UserName] = @UserName"
            UpdateCommand="UPDATE [Users] SET [UserName] = @UserName WHERE [UserID] = @UserID">
            <SelectParameters>
                <asp:Parameter Name="UserName" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="UserID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="UserName" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="UserName" Type="String" />
                <asp:Parameter Name="UserID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        
        
        <asp:SqlDataSource ID="sdsUserVSDFiles" runat="server" ConnectionString="<%$ ConnectionStrings:Database %>"
            DeleteCommand="DELETE FROM [UserVSDFiles] WHERE [VSDFileID] = @VSDFileID" 
            InsertCommand="INSERT INTO [UserVSDFiles] ([BatFileID], [UserID], [VSDFilename], [NodesCount], [FilesCount], [Title]) VALUES (@BatFileID, @UserID, @VSDFilename, @NodesCount, @FilesCount, @Title)"
            ProviderName="<%$ ConnectionStrings:Database.ProviderName %>" 
            SelectCommand="SELECT [VSDFileID], [BatFileID], [UserID], [VSDFilename], [NodesCount], [FilesCount], [Title] FROM [UserVSDFiles] WHERE  VSDFilename = @VSDFilename"
            UpdateCommand="UPDATE [UserVSDFiles] SET [BatFileID] = @BatFileID, [UserID] = @UserID, [VSDFilename] = @VSDFilename, [NodesCount] = @NodesCount, [FilesCount] = @FilesCount, [Title] = @Title WHERE [VSDFileID] = @VSDFileID">
             <SelectParameters>
                <asp:Parameter Name="VSDFilename" Type="String" />
            </SelectParameters>
           <DeleteParameters>
                <asp:Parameter Name="VSDFileID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="BatFileID" Type="Int32" />
                <asp:Parameter Name="UserID" Type="Int32" />
                <asp:Parameter Name="VSDFilename" Type="String" />
                <asp:Parameter Name="NodesCount" Type="Int32" />
                <asp:Parameter Name="FilesCount" Type="Int32" />
                <asp:Parameter Name="Title" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="BatFileID" Type="Int32" />
                <asp:Parameter Name="UserID" Type="Int32" />
                <asp:Parameter Name="VSDFilename" Type="String" />
                <asp:Parameter Name="NodesCount" Type="Int32" />
                <asp:Parameter Name="FilesCount" Type="Int32" />
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="VSDFileID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        
    </form>
</body>
</html>
